<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>

    class Phone {
        name;
        #price;
        constructor(name, price) {
            this.name = name;
            this.#price = price;
        }
        getPrice() {
            // 在类 内部可以获取到价格
            return this.#price;
        }
    }
    let xiaomi = new Phone("小米", 1999);
    // 实例获取不到私有属性
    console.log(xiaomi, xiaomi.name);
    console.log(xiaomi.getPrice());


</script>

</html>